cc.Class({
    extends: cc.Component,

    properties: {
        dieAudio: {
            default: null,
            url: cc.AudioClip
        },
    },

    // use this for initialization
    onLoad: function () {

        // 父视图对象
        this.mainObj = this.node.parent.getComponent('Main');

        // 开启碰撞监听
        cc.director.getCollisionManager().enabled = true;

        // 添加点击时间的监听
        this.addMouseTouch();
    },

    // 添加屏幕点击事件的监听
    addMouseTouch: function() {
        var self = this;
        // 添加监听
        var touchManager = {
            event: cc.EventListener.TOUCH_ONE_BY_ONE,
            onTouchBegan: function(touches, event) {
               // 在原有位置的基础上，以为y轴140  -> 地刺之间的间隔 
                var goAction = cc.moveBy(0.2, cc.p(0, diciIntevalY));
                self.node.runAction(goAction);
                return true;
            },
            onTouchMoved: function(touches, event) {},
            onTouchEnded: function(touches, event) {},
            onTouchCancelled: function(touches, event) {},
        }
        cc.eventManager.addListener(touchManager, this.node);
    },

    // 监听碰撞
    onCollisionEnter: function(other, self) {
        // 监听
        // cc.log("碰撞的hero =>" + other.node.group + "碰撞的地刺 =>" + self.node.group);
        this.mainObj.onCollisionForHeroAndDici();
    },

    // called every frame, uncomment this function to activate update callback
    // update: function (dt) {

    // },
});
